setwd("/home1/30/jc227089/Quoll_model/PBS_files")

tt<-1:100

script.file<-'/home1/30/jc227089/evo-dispersal/Quoll_model/Quoll_model.R'

for (ii in 1:length(tt)) {
	##create the sh file
	zz = file(paste('jobrun_',tt[ii],'.sh',sep=''),'w')
		cat('##################################\n',file=zz)
		cat('#!/bin/sh\n',file=zz)
		cat('cd $PBS_O_WORKDIR\n',file=zz)
		cat("R CMD BATCH --no-save --no-restore '--args sr=5000 file.ID=",tt[ii],"' ",script.file,' jobrun_',tt[ii],'.Rout \n',sep='',file=zz)
		cat('##################################\n',file=zz)
	close(zz)
			
	#submit the job
	system(paste('qsub -m n jobrun_',tt[ii],'.sh',sep=''))
}
